package com.gateway.config;

import com.gateway.handler.CustomRoutePredicateHandler;
import org.springframework.cloud.gateway.config.GlobalCorsProperties;
import org.springframework.cloud.gateway.handler.FilteringWebHandler;
import org.springframework.cloud.gateway.handler.RoutePredicateHandlerMapping;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;

/**
 * @author xiangminwen
 * @date 2025/2/21 14:20
 */
@Configuration
public class CommonConfig {

//    @Bean
//    @Primary
    public RoutePredicateHandlerMapping customRoutePredicateHandlerMapping(
            FilteringWebHandler webHandler, RouteLocator routeLocator,
            GlobalCorsProperties globalCorsProperties, Environment environment) {
        return new CustomRoutePredicateHandler(webHandler, routeLocator,
                globalCorsProperties, environment);
    }

}
